package stu.wingsmaker.artofsubway.model.adapter;

import java.util.ArrayList;

import stu.wingsmaker.artofsubway.R;
import stu.wingsmaker.artofsubway.model.ConcertListData;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ConcertListAdapter extends ArrayAdapter<ConcertListData> {

	private ArrayList<ConcertListData> items;
	 
    public ConcertListAdapter(Context context, int textViewResourceId,
            ArrayList<ConcertListData> items) {
        super(context, textViewResourceId, items);
        this.items = items; }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
             
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.concert_listview, null);
        }
        ConcertListData custom_list_data = items.get(position);
 
        if (custom_list_data != null) {
            //�ϳ��� �̹������ 2���� �ؽ�Ʈ�� ������ �޾ƿ´�.
            ImageView iv = (ImageView)v.findViewById(R.id.subwayNumber);
            TextView tv_Main = (TextView) v.findViewById(R.id.concertNameText);
            TextView tv_Sub = (TextView) v.findViewById(R.id.artistNameText);
             
            // ���� item�� position�� �´� �̹����� ���� �־��ش�.          
            iv.setBackgroundResource(custom_list_data.getImage_ID());
            tv_Main.setText(custom_list_data.getMain_Title());
            tv_Sub.setText(custom_list_data.getSub_Title());
        }
 
        return v;
    }
}

